rem @echo OFF
rem
rem **************************************************************************
rem  Script installs and prepares the projects for testing using the 
rem  FunFX framework.
rem
rem **************************************************************************
rem
echo Enabling FunFX testing....
if "%1" == "" goto help
if "%2" == "" goto help

set RUBY_HOME=%1
set FLEX_HOME=%2
if not exist "%FLEX_HOME%\bin\mxmlc.exe" goto noFlexSDK
if not exist "%RUBY_HOME%\bin\ruby.exe" goto noRuby
if not exist "%RUBY_HOME%\bin\gem.bat" goto noGem

goto install

:noFlexSDK
echo Invalid Flex home parameter
goto end

:noRuby
echo Ruby home parameter is invalid
goto end
:noRubyGem
echo Requires a Ruby installation with GEM to install required libraries
goto end

:help 
echo Missing arguments for installing FunFX
echo To install FunFX you need to have Ruby and Flex SDK installed. 
echo The install procedure requires a reference to Ruby home and the SDK. 
echo Usage: install_funfx.cmd "ruby_home" "flex_home"
echo 	install_funfx.cmd c:\ruby c:\flex_sdk\sdks\3.1.0\
echo Please try again with correct parameters
goto end

:install
echo Installing required Ruby Gem's for FunFX... this may take a few minutes, got get a coffee
set PATH=%PATH%;%RUBY_HOME%\bin;
echo Adding %RUBY_HOME%\bin to your PATH environment variable
call gem install -y firewatir
call gem install -y funfx-reqs\funfx-0.2.0.gem 
call gem install -y Watir
call gem install -y cucumber
call gem install win32console

echo Ruby gems installed...

echo Copying required SWC libraries
call copy %RUBY_HOME%\lib\ruby\gems\1.8\gems\funfx-0.2.0\ext\FunFx.swc blaze-poc-flex\libs
call copy %FLEX_HOME%\frameworks\libs\automation_agent.swc blaze-poc-flex\libs
call copy %FLEX_HOME%\frameworks\libs\automation.swc blaze-poc-flex\libs
call copy %FLEX_HOME%\frameworks\libs\automation_dmv.swc blaze-poc-flex\libs

call copy funfx-reqs\AutoQuickEnv.xml blaze-poc-web\src\main\webapp\assets\flex

echo Copied automation SWC files to "blaze-poc-flex\libs"
echo FunFX now installed, now go test!
goto end

:end
